import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/views/layout/Layout'
import NoPage from '@/views/layout/404'
import activityManageRouter from './activityManageRouter'
import baseSettingRouter from './baseSettingRouter'
import dataReportsRouter from './dataReportsRouter'
import doc from './doc'

import NavLayout from '../views/layout/NavLayout'
Vue.use(Router)
/**
* hidden: true                   隐藏在菜单栏
* meta : {
    title: 'title'               菜单标题&tab标题
    icon: 'svg-name'             菜单图标
  }
**/

export let constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/user/login'),
    hidden: true
  },
  {
    path: '/404',
    component: Layout,
    children: [
      {
        path: 'index',
        component: NoPage,
        meta: { title: 'NoPage', icon: '' }
      }
    ],
    hidden: true
  },
  {
    path: '', redirect: '/index', hidden: true
  }
]
// 如果非正式环境 引入文档路由
if (process.env.NODE_ENV !== 'production') {
// constantRouterMap = constantRouterMap.concat(require('./doc').default)
}
// 常量路由
export default new Router({
  mode: 'history', // 后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/activityManage',
    redirect: '/activityManage/activityLists/activityList',
    component: NavLayout,
    meta: { title: '活动管理' },
    children: [...activityManageRouter]
  },
  {
    path: '/dataReports',
    redirect: '/dataReports/activityOrders/voucherOrder',
    component: NavLayout,
    meta: { title: '数据报表' },
    children: [...dataReportsRouter]
  },
  {
    path: '/baseSetting',
    redirect: '/baseSetting/accountManage/AccountList',
    component: NavLayout,
    meta: { title: '基础设置' },
    children: [...baseSettingRouter]
  },
  {
    path: '/doc',
    redirect: '/doc/example/table',
    component: NavLayout,
    meta: { title: '示例模板' },
    children: [...doc]
  }
]
